﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mang
{
    public class MyArray<T>
    {
        private T[] a = new T[100];
        private int n;
        private ThuatToanSapXep<T> thuatToan;
        private TieuChiSapXep<T> tieuChi;

        public TieuChiSapXep<T> TieuChi
        {
            get { return tieuChi; }
            set { tieuChi = value; }
        }

        public ThuatToanSapXep<T> ThuatToan
        {
            get { return thuatToan; }
            set { thuatToan = value; }
        }

        public void Nhap(T[] b, int m)
        {
            n = m;
            for (int i = 0; i < n; i++)
            {
                a[i] = b[i];
            }
        }

        public void Xuat()
        {
            for (int i = 0; i < n; i++)
            {
                Console.Write(a[i].ToString() + "\n");
            }
            Console.Write("\n");
        }

        public void SapXep()
        {
            if (tieuChi == null)
                thuatToan.SapXep(a, n);
            else
                thuatToan.SapXep(a, n, tieuChi);
        }

        public void SapXep(ThuatToanSapXep<T> _thuattoan)
        {
            if(tieuChi == null)
                _thuattoan.SapXep(a, n);
            else
                _thuattoan.SapXep(a, n, tieuChi);
        }

        public void SapXep(TieuChiSapXep<T> tc)
        {
            if (tc == null)
                thuatToan.SapXep(a, n);
            else
                thuatToan.SapXep(a, n, tc);
        }
        public void SapXep(ThuatToanSapXep<T> _thuattoan, TieuChiSapXep<T> tc)
        {
            if (tc == null)
                _thuattoan.SapXep(a, n);
            else
                _thuattoan.SapXep(a, n, tc);
        }
    }
}
